﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using DuncanDAL;
using BLL.BaseDictionaryService;

namespace BLL.BudgetService
{
    /// <summary>
    /// 查询所有预算的业务对象
    /// </summary>
    public class QueryBudgetTransaction:ICommand
    {
        public QueryBudgetTransaction()
        { 
            
        }

        protected IList<T_BudgetObject> budgets;

        #region ICommand 成员

        public void Execute()
        {
            QueryPayCategoryTransaction objQueryPayCategoryTransaction = new QueryPayCategoryTransaction();
            objQueryPayCategoryTransaction.Execute();
            IList<D_PayCategoryObject> payCategorys = objQueryPayCategoryTransaction.PayCategorys;

            BudgetDataService objBudgetDataService = new BudgetDataService();
            budgets = objBudgetDataService.QueryAll();

            foreach (T_BudgetObject item in budgets)
            {
                item.PayCategory = payCategorys.SingleOrDefault(x => x.Db_OID == item.Db_PayCategory).Db_CategoryName;
            }
        }

        #endregion
    }
}
